
<% var html={ %>
<div class='row zq-row'>
    <div id="googleMap" ></div>

</div>
<% }; %>
<% var js={ %>
<script type="text/javascript" src="http://ditu.google.cn/maps/api/js?key=AIzaSyCttnir7GHS6XxOoIT64aPT_BW9sIXC3q8&sensor=false&libraries=geometry"></script>
<script>
    layui.use(['layer','laydate'], function(){

    });
    var center = new google.maps.LatLng(39.9054905603894,116.39763216225809);
    var map;
    var AICON=[];
    var BICON=[];
    var AP=[];
    var BP=[];
    $(function () {
        var height = $(window).height() - 20;
        var width = $("#googleMap").parent().width();
        $("#googleMap").css("height", height + "px").css("width", width + "px");
        init();
    })
    function init(){

        zqPost("/console/machine/abline/json",{},function(data){
            if(data.code==1){
                map=null;
                var liatPoint = data.data==undefined?undefined:data.data;
                if(liatPoint!=undefined){
                    $(liatPoint).each(function(i,ponit){
                        if(i==0){
                            center=new google.maps.LatLng(ponit.apointResp.lat,ponit.apointResp.lng);
                        }
                        AP.push(new google.maps.LatLng(ponit.apointResp.lat,ponit.apointResp.lng));
                        BP.push(new google.maps.LatLng(ponit.bpointResp.lat,ponit.bpointResp.lng));
                        AICON.push(ponit.apointResp.icon);
                        BICON.push(ponit.bpointResp.icon);
                    });
                }
                var mapProp = {
                    center:center,
                    zoom:18,
                    mapTypeId:google.maps.MapTypeId.HYBRID
                };
                if(map!=undefined){
                    var ma= new google.maps.Marker({
                        position:  center
                    });
                    map.panTo(ma.getPosition());
                }else{
                    map=new google.maps.Map(document.getElementById("googleMap")
                        ,mapProp);
                }
                try{
                    $(AP).each(function(i,o){
                        var bpi =  BP[i];
                        var line = [];
                        line.push(o);
                        line.push(bpi);

                        var flightPath=new google.maps.Polyline({
                            path:line,
                            strokeColor:"#FF9900",
                            strokeOpacity:1,
                            strokeWeight:10
                        });
                        flightPath.setMap(map);
                        var apoint = new google.maps.Marker({
                            position: new google.maps.LatLng(o.lat(),o.lng()),
                            icon:AICON[i]
                        });
                        apoint.setMap(map);
                        var bpoint = new google.maps.Marker({
                            position: new google.maps.LatLng(bpi.lat(),bpi.lng()),
                            icon:BICON[i]
                        });
                        bpoint.setMap(map);
                    });
                }catch (e){
                    alert(e)
                }

            }else{
                alert("系统出错")
            }
        });
    }
</script>
<% }; %>

<% layout("/view/console/skins/skin_2/layout.html", {js:js,html:html}) {} %>